package cn.aitstone;

import com.netflix.loadbalancer.RandomRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
/**
 * @Description: 订单的启动类
 * @Author: Sheldon
 * @Version: 1.0
 * @Date:  2022/7/27 20:31
 */
@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
public class OrderStarterApp {
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

    /**
    * @Title: randomRule
    * @Description: 负载均衡算法
    * @Author: Sheldon
    * @Version: 1.0
    * @Date:  2022/7/28 11:05  
    * @Parameters: []
    * @Return com.netflix.loadbalancer.RandomRule
    */
    @Bean
    public RandomRule randomRule(){
        return new RandomRule();
    }
    
    public static void main(String[] args) {
        SpringApplication.run(OrderStarterApp.class, args);
    }
}
